import React, { PureComponent } from 'react';
import { connect } from "dva"
import { Icon, Menu, Dropdown, Button, Modal } from 'antd';
import ToolConfigModals from '../../components/toolConfigModals';
import ProjectForm from '../../components/forms/project';
import CommondLine from '../../components/commondLine';
import ProjectDirecTree from '../../components/projectDirecTree'
import BridgeForm from '../../components/forms/bridge'
import UploadGroupRoad from '../../components/forms/uploadGroupRoad'
import ConfigSpan from '../../components/forms/configSpan'
import TopComponents from '../../components/forms/topComponents'
import BotComponents from '../../components/forms/botComponents'
import AttachComponents from '../../components/forms/attachComponents'
import SubmitResults from '../../components/forms/submitResults'
import RoadPoints from "../../components/forms/roadPoints"
import OtherLines from "../../components/forms/otherlines"
import ComponentEdit from "../../components/forms/componentEdit"
import PierComponents from "../../components/forms/pierComponents"
import SectionComponents from "../../components/forms/sectionComponents"
import UnionComponent from "../../components/forms/unionComponent"
import TopStructures from "../../components/forms/topStructures"
import BotStructures from "../../components/forms/botStructures"
import RoadDesign from "../../components/forms/roadDesign"
import BridgeMainList from "../../components/forms/bridgeMainList"
import BridgeChildList from "../../components/forms/bridgeChildList"
import ElevationCal from "../../components/forms/elevationCal"
import PositionCal from "../../components/forms/positionCal"
import BeamLenCal from "../../components/forms/beamLenCal"
import PinnerCal from "../../components/forms/pinnerCal"
import Adminicula from "../../components/forms/adminicula"
import AdminiculaDetail from "../../components/forms/adminiculaDetail"
import CrossSectionList from "../../components/forms/crossSectionList"
import "../../Common.less"
import "./index.less"
class Design extends PureComponent {
    constructor(props) {
        super(props)
        this.state = {
            svalue: "",
            pageCode: "",
            commondShow: false,
            curIndex: 0,
            reset: false,
            modalContext: null,
            showBg: false,
            newPageTitle: "项目信息",
            newPage: false,
            tloading: true,
            formContext: null,
            loading: false,
            execlogs: [],
            logList: [],
            execIndex: 0,
            execvalue: "",
            historylog: []
        }
        this.goNewPage = this.goNewPage.bind(this)
        this.goInnerPage = this.goInnerPage.bind(this)
        this.submit = this.submit.bind(this)
        this.reset = this.reset.bind(this)
        this.continueEdit = this.continueEdit.bind(this)
        this.backHome = this.backHome.bind(this)
        this.calculateBridge = this.calculateBridge.bind(this)
        this.updateNewPageTitle = this.updateNewPageTitle.bind(this)
        this.showCommond = this.showCommond.bind(this)
        this.modalConfirm = this.modalConfirm.bind(this)
        this.calculate = this.calculate.bind(this)
        this.getFormValues = this.getFormValues.bind(this)
        this.getSocketNews = this.getSocketNews.bind(this)
        this.scrollLatest = this.scrollLatest.bind(this)
        this.clearLogs = this.clearLogs.bind(this)
        this.closeBg = this.closeBg.bind(this)
        this.setFormular = this.setFormular.bind(this)
        this.getRoadId = this.getRoadId.bind(this)
        this.menuClick = this.menuClick.bind(this)
        this.menuClick2 = this.menuClick2.bind(this)
        this.menuClick3 = this.menuClick3.bind(this)
        this.showBg=this.showBg.bind(this)
    }
    getSocketNews(news) {
        let { logList } = this.state;
        logList.push(news)
        this.setState({
            execlogs: [{ message: "python  script.py" }],
            logList: [...logList]
        })
    }
    showBg() {
        this.setState({
            showBg: true
        })
    }
    closeBg() {
        this.setState({
            showBg: false
        })
    }
    clearLogs() {
        this.setState({
            execlogs: [],
            logList: []
        })
    }
    getFormValues() {
        return new Promise((resolve, reject) => {
            this.props.form.validateFields((error, values) => {
                if (!error) {
                    resolve(values)
                } else {
                    reject(error)
                }
            });
        })
    }
    componentWillUnmount() {
        if (this.st) {
            clearTimeout(this.st)
        }
        if (this.st2) {
            clearTimeout(this.st2)
        }
    }
    scrollLatest() {
        const node = document.querySelector(".logContent")
        if (node && node.scrollHeight) {
            node.scrollTop = node.scrollHeight
        }

    }
    componentWillMount() {
        if (!sessionStorage.getItem("isLogin")) {
            this.props.history.push("/login")
            return;
        }
    }
    componentDidMount() {

        if (this.state.execlogs && this.state.execlogs.length) {
            this.scrollLatest()
        }
        this.st2 = setTimeout(() => {
            clearTimeout(this.st2)
            this.setState({
                tloading: false
            })
        }, 250)
        // this.goInnerPage(null, "", "项目信息")
    }
    backHome() {
        this.goInnerPage(null, "", "项目信息")
    }
    modalConfirm() {//
        if (this.state.formContext && this.state.formContext.refresh) {
            this.state.formContext.refresh()
        }
    }
    setFormular(lar) {
        this.state.formContext.setFormular(lar)
    }
    submitSuccess(extraData) {
        this.st = setTimeout(() => {
            if (this.st) {
                clearTimeout(this.st)

                Modal.confirm({
                    title: "提示",
                    content: extraData ? extraData.msg : "操作成功",
                    okText: "确定",
                    centered: true,
                    cancelText: "取消",
                    onOk: () => {
                        if (extraData && extraData.pre) {
                            this.goInnerPage(null, extraData.pre, extraData.preText, extraData)
                        }

                    },
                    onCancel() {

                    }
                })
                this.setState({
                    loading: false
                })
            }
        }, 50)
    }
    continueEdit() {
        let { curIndex, historylog } = this.state
        let { newPage, newPageTitle, pageCode, extra } = historylog[curIndex - 1]
        if (pageCode == "results") {
            curIndex -= 2
        } else {
            if (curIndex - 1 >= 0) {
                curIndex -= 1
            }
        }
        this.setState({
            newPage,
            newPageTitle,
            pageCode,
            curIndex,
            extra
        })
        // if(newPage==true){
        //     this.goNewPage(null,pageCode,pageTitle)
        // }else{
        //     this.goInnerPage(null,pageCode,pageTitle)

        // }

    }
    async goNewPage(e, code, title, extraData) {
        let { pageCode, newPageTitle, newPage, historylog, curIndex, extra } = this.state
        let reset = extra && extraData != extra ? true : false

        if (historylog && historylog.length <= 9) {
            historylog.push({
                pageCode,
                newPageTitle,
                newPage,
                extra
            })
            curIndex += 1;
        } else {
            historylog.shift()
            historylog.push({
                pageCode,
                newPageTitle,
                newPage,
                extra
            })
            curIndex = 10;
        }

        if (e) {
            e.preventDefault();
        }
        await this.setState({
            reset,
            newPage: !newPage
        })
        await this.setState({
            newPage: newPage
        })
        this.setState({
            loading: true,
            lastExtra: extra,
            lastNewPage: newPage,
            lastPageCode: pageCode,
            lastNewPageTitle: newPageTitle,
            newPage: true,
            newPageTitle: title,
            pageCode: code,
            historylog,
            extra: extraData,
            curIndex
        })
        this.st = setTimeout(() => {
            if (this.st) {
                this.setState({
                    loading: false
                })
                clearTimeout(this.st)
            }
        }, 50)

    }
    async goInnerPage(e, code, title, extraData) {
        let { pageCode, newPageTitle, newPage, historylog, curIndex, extra } = this.state
        if (historylog && historylog.length <= 9) {
            historylog.push({
                pageCode,
                newPageTitle,
                newPage,
                extra
            })
            curIndex += 1;
        } else {
            historylog.shift()
            historylog.push({
                pageCode,
                newPageTitle,
                newPage,
                extra
            })
            curIndex = 10;
        }
        if (e) {
            e.preventDefault();
        }
        await this.setState({
            pageCode: null
        })
        this.setState({
            extra: extraData,
            lastExtra: extra,
            lastNewPage: newPage,
            lastPageCode: pageCode,
            newPageTitle: newPageTitle,
            newPage: false,
            newPageTitle: title,
            pageCode: code,
            historylog,
            curIndex
        })
    }
    async submit(e) {
        this.setState({
            loading: true
        })
        e.preventDefault()
        let { pageCode, formContext } = this.state;

        switch (pageCode) {
            case "":
                if (formContext.onConfirm) {
                    formContext.onConfirm().then((res) => {
                        this.submitSuccess({ msg: res })
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "uploadRoads":

                if (formContext.onConfirm) {
                    formContext.onConfirm().then((res) => {
                        this.submitSuccess({ pre: "roadDesign", preText: "道路设计", msg: res })
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "addBridge":
                if (formContext.onConfirm) {
                    formContext.onConfirm().then((res) => {
                        this.submitSuccess({ pre: "bridgeMainList", preText: "桥梁设计", msg: res })
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "editBridge":
                if (formContext.onConfirm) {
                    formContext.onConfirm().then((res) => {
                        this.submitSuccess({ pre: "bridgeMainList", preText: "桥梁设计", msg: res })
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "configSpan":
                if (formContext.onConfirm) {
                    formContext.onConfirm().then((res) => {
                        this.submitSuccess({ msg: res })
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "topComponents":
                if (formContext.onConfirm) {

                    formContext.onConfirm().then(() => {
                        this.submitSuccess()
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "botComponents":
                if (formContext.onConfirm) {

                    formContext.onConfirm().then(() => {
                        this.submitSuccess()
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            case "componentEdit":
                if (formContext.onConfirm) {
                    formContext.onConfirm().then(() => {
                        this.submitSuccess()
                    }).catch(err => {
                        this.setState({
                            loading: false
                        })
                    })
                }
                break;
            default:
                break;
        }
    }
    menuClick(e) {
        if (e.key == 0) {
            this.goInnerPage(null, "ElevationCal", "任意地点高程计算")
        } else if (e.key == 1) {
            this.goInnerPage(null, "PositionCal", "任意地点坐标计算")
        } else if (e.key == 2) {
            this.goInnerPage(null, "BeamLenCal", "预制梁长计算")
        } else if (e.key == 3) {
            this.goInnerPage(null, "PinnerCal", "垫石高程计算")
        } else if (e.key == 4) {
            this.props.history.push({
                pathname: "/continuousRigidFrame"
            })
        }
    }
    menuClick2(e) {
        if (e.key == 0) {
            this.goInnerPage(null, "adminicula", "支座")
        }
    }
    menuClick3(e) {
        if (e.key == 0) {
            let a = window.open("about:blank")
            a.location = "/crossSection"
        }
    }
    calculateBridge(e) {
        if (e) {
            e.preventDefault()
        }
        let { modalContext } = this.state;
        modalContext.updateModal({
            visible: true,
            title: "选择桥梁",
            event: { code: "switchBridge" },
            extra: {

            }
        })
    }
    getRoadId(id) {
        this.setState({
            roadId: id
        })
    }
    updateNewPageTitle(title) {
        this.setState({
            newPageTitle: title
        })
    }
    reset() {
        let { newPage, pageCode, formContext } = this.state;
        switch (pageCode) {
            case "":
                if (formContext && formContext.reset) {
                    formContext.init()
                }
                break;
            case "uploadRoads":
                if (formContext && formContext.reset) {
                    formContext.reset()
                }
                break;
            case "addBridge":
                if (formContext && formContext.reset) {
                    formContext.reset()
                }
                break;
            case "editBridge":
                if (formContext && formContext.reset) {
                    formContext.init()
                }
                break;
            case "configSpan":
                if (formContext && formContext.reset) {
                    formContext.reset()
                }
                break;
            case "topComponents":

                if (formContext && formContext.reset) {
                    formContext.reset()
                }
                break;
            case "botComponents":
                if (formContext && formContext.reset) {
                    formContext.reset()
                }
                break;
            case "componentEdit":
                if (formContext && formContext.reset) {
                    formContext.reset()
                }
                break;
            default:
                break;
        }
    }
    calculate(e) {
        e.preventDefault()
        let { modalContext } = this.state;
        modalContext.updateModal({
            visible: true,
            title: "构件高度计算",
            event: { code: "calculate" },
            extra: {

            }
        })
    }
    async showCommond(e, show) {
        if (show) {
            this.setState({
                commondShow: show
            })
        } else {
            this.setState({
                commondShow: !this.state.commondShow
            })
        }
    }
    render() {
        const { project, dictlist } = this.props;
        const { logList, tloading, execlogs, showBg, pageCode, svalue, commondShow, newPage, reset, newPageTitle, treeContext, modalContext, roadId, extra, loading, formContext } = this.state

        const menu = (
            <Menu onClick={this.menuClick2}>
                <Menu.Item key="0">
                    支座
                </Menu.Item>
                <Menu.Item key="1">
                    护栏
                </Menu.Item>
                <Menu.Item key="2">
                    伸缩缝
                </Menu.Item>
                <Menu.Item key="3">
                    桥面铺装
                </Menu.Item>
                <Menu.Item key="4">
                    排水
                </Menu.Item>
            </Menu>
        );
        const menu2 = (
            <Menu onClick={this.menuClick}>
                <Menu.Item key="0">
                    任意地点高程计算
                </Menu.Item>
                <Menu.Item key="1">
                    任意地点坐标计算
                </Menu.Item>
                <Menu.Item key="2">
                    梁长计算
                </Menu.Item>
                <Menu.Item key="3">
                    垫石计算
                </Menu.Item>
                <Menu.Item key="4">
                    大跨径连续钢构
                </Menu.Item>
            </Menu>
        );
        const menu3 = (
            <Menu onClick={this.menuClick3}>
                <Menu.Item key="0">
                    截面库
                </Menu.Item>
            </Menu>
        );
        return (
            <div className="workBox" style={tloading ? { opacity: 0 } : { opacity: 1 }}>
                <div className="topNav">
                    <div className="navLeft">
                        <div onClick={e => {
                            e.preventDefault();
                            // if (pageCode) {
                            //     this.continueEdit()
                            // } else {
                            history.go(-1)
                            // }
                        }}><Icon type="left" /></div>
                        <div onClick={e => this.goInnerPage(e, "", "项目信息")}>{project ? project.name : ''}</div>
                    </div>
                    <div className="navMiddle">
                        <div onClick={e => this.goInnerPage(e, 'uploadRoads', '路线导入')}>
                            <div><img src="./static/images/importRoad.png" alt="" /></div>
                            <div>路线导入</div>
                        </div>
                        <div onClick={e => this.goInnerPage(e, 'addBridge', '创建桥梁')}>
                            <div><img src="./static/images/addBridge.png" alt="" /></div>
                            <div>创建桥梁</div>
                        </div>
                        <div onClick={e => this.goInnerPage(e, 'configSpan', '添加布跨')}>
                            <div><img src="./static/images/addSpan.png" alt="" /></div>
                            <div>添加布跨</div>
                        </div>
                        <div onClick={e => {
                            this.goInnerPage(e, 'topComponents', '上部结构')
                        }}>
                            <div><img src="./static/images/topStructure.png" alt="" /></div>
                            <div>上部结构</div>
                        </div>
                        <div onClick={e => {
                            this.goInnerPage(e, 'botComponents', '下部结构')
                        }}>
                            <div><img src="./static/images/botStructure.png" alt="" /></div>
                            <div>下部结构</div>
                        </div>
                        <Dropdown overlay={menu}>
                            <div className="gray" onClick={null}>
                                <div><img src="./static/images/attachComponent.png" alt="" /></div>
                                <div>附属结构</div>
                            </div>
                        </Dropdown>
                        <div className="gray" onClick={null}>
                            <div><img src="./static/images/jaStructure.png" alt="" /></div>
                            <div>交安结构</div>
                        </div>
                        <div onClick={this.calculateBridge}>
                            <div><img src="./static/images/xml.png" alt="" /></div>
                            <div>生成桥梁</div>
                        </div>
                        <Dropdown overlay={menu2}>
                            <div className="gray" onClick={null}>
                                <div><img src="./static/images/calculate.png" alt="" /></div>
                                <div>计算</div>
                            </div>
                        </Dropdown>
                        <div>
                            <div><img src="./static/images/stastic.png" alt="" /></div>
                            <div>统计</div>
                        </div>
                        <div>
                            <div><img src="./static/images/libary.png" alt="" /></div>
                            <div>构件库</div>
                        </div>
                        <div onClick={e => {
                            this.props.history.push({
                                pathname: "/renforce"
                            })
                        }}>
                            <div><img src="./static/images/libary.png" alt="" /></div>
                            <div>配筋</div>
                        </div>
                        <div className={`${!newPage ? '' : 'gray'}`} onClick={!newPage ? this.showCommond : null}>
                            <div><img src="./static/images/calculate.png" alt="" /></div>
                            <div>命令行</div>
                        </div>

                    </div>
                    <div className="navRight">
                        <Dropdown overlay={menu3}>
                            <div className="absMiddle">
                                <div><img src="./static/images/more.png" alt="" /></div>
                                <div>更多</div>
                            </div>
                        </Dropdown>

                    </div>
                </div>
                <div className='designMain'>

                    <div className={`mainLeft`}>
                        <div className="title">
                            <div>项目树</div>
                            <div>
                                <div className="inputBox">
                                    <input onChange={e => { e.persist(); e.preventDefault(); this.setState({ svalue: e.target.value }) }} value={svalue} type="text" />
                                    {
                                        svalue && focus ? <Icon onClick={e => { e.persist(); e.preventDefault(); this.setState({ svalue: '' }) }} type="close-circle" /> : null
                                    }
                                </div>
                                <div className="iconBox">
                                    <Icon type="search" />
                                    <Icon type="unordered-list" />
                                </div>
                            </div>
                        </div>
                        <div>
                            <ProjectDirecTree getRoadId={this.getRoadId} goInnerPage={this.goInnerPage} onLoaded={(context) => {
                                this.setState({
                                    treeContext: context
                                })
                            }} project={project}></ProjectDirecTree>
                        </div>
                    </div>
                    <div className={`mainRight`}>
                        <div className={`content`}>
                            <div className="title"><div></div>{newPageTitle}</div>
                            {/* <Drag></Drag> */}
                            {(!newPage) && pageCode == "" ? <ProjectForm treeContext={treeContext} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} mode='edit' project={this.props.project}></ProjectForm> : undefined}
                            {(!newPage) && pageCode == "bridgeChildList" ? <BridgeChildList extra={extra} treeContext={treeContext} goInnerPage={this.goInnerPage}></BridgeChildList> : undefined}
                            {(!newPage) && pageCode == "bridgeMainList" ? <BridgeMainList treeContext={treeContext} goInnerPage={this.goInnerPage}></BridgeMainList> : undefined}
                            {
                                (!newPage) && pageCode == "roadDesign" ? <RoadDesign treeContext={treeContext} goInnerPage={this.goInnerPage}></RoadDesign> : undefined
                            }
                            {(!newPage) && pageCode == "editBridge" ? <BridgeForm mode="edit" updateNewPageTitle={this.updateNewPageTitle} treeContext={treeContext} bridgeData={extra} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} dictlist={dictlist} project={project} ></BridgeForm> : null}
                            {(!newPage) && pageCode == "pierComponents" ? <PierComponents commondShow={commondShow} treeContext={treeContext} modalContext={modalContext} mode="edit" goNewPage={this.goNewPage} goInnerPage={this.goInnerPage} pierData={extra} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} dictlist={dictlist} project={project} ></PierComponents> : null}
                            {(!newPage) && pageCode == "sectionComponents" ? <SectionComponents commondShow={commondShow} treeContext={treeContext} modalContext={modalContext} mode="edit" goNewPage={this.goNewPage} goInnerPage={this.goInnerPage} sectionData={extra} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} dictlist={dictlist} project={project} ></SectionComponents> : null}
                            {(!newPage) && pageCode == "componentEdit" ? <ComponentEdit mode="edit" extra={extra} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} dictlist={dictlist} project={project} ></ComponentEdit> : null}
                            {(!newPage) && pageCode == "topStructure" ? <TopStructures commondShow={commondShow} extra={extra} treeContext={treeContext} modalContext={modalContext} bridgeData={extra} goNewPage={this.goNewPage} goInnerPage={this.goInnerPage} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} mode='edit' project={this.props.project}></TopStructures> : null}
                            {(!newPage) && pageCode == "botStructure" ? <BotStructures commondShow={commondShow} extra={extra} treeContext={treeContext} modalContext={modalContext} bridgeData={extra} goNewPage={this.goNewPage} goInnerPage={this.goInnerPage} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} mode='edit' project={this.props.project}></BotStructures> : null}
                            {
                                (!newPage) && pageCode && pageCode.includes('RoadPoints') ? <RoadPoints className={`${pageCode.includes('RoadPoints') ? 'none' : ''}`} type={pageCode.replace('RoadPoints', '')} roadId={roadId}></RoadPoints> : null
                            }
                            {
                                (!newPage) && pageCode && pageCode.includes('OtherLines') ? <OtherLines className={`${pageCode.includes('OtherLines') ? 'none' : ''}`} type={pageCode.replace('OtherLines', '')} extra={extra}></OtherLines> : null
                            }
                            {!newPage && pageCode == 'configSpan' ? <ConfigSpan modalContext={modalContext} project={project} treeContext={treeContext} dictlist={dictlist} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} className={`${newPage && pageCode == 'configSpan' ? '' : 'none'}`}></ConfigSpan> : null}
                            {/* <UnionComponent></UnionComponent> */}
                            {!newPage && pageCode == 'uploadRoads' ? <UploadGroupRoad treeContext={treeContext} extra={extra} project={project} goInnerPage={this.goInnerPage} dictlist={dictlist} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} className={`${newPage && pageCode == 'uploadRoads' ? '' : 'none'}`}></UploadGroupRoad> : null}
                            {!newPage && pageCode == 'addBridge' ? <BridgeForm treeContext={treeContext} mode="add" project={project} dictlist={dictlist} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} className={`${newPage && pageCode == 'addBridge' ? '' : 'none'}`}></BridgeForm> : null}
                            {!newPage && pageCode == 'topComponents' ? <TopComponents commondShow={commondShow} reset={reset} treeContext={treeContext} bridgeData={extra} modalContext={modalContext} project={project} treeContext={treeContext} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} className={`${newPage && pageCode == 'topComponents' ? '' : 'none'}`}></TopComponents> : null}
                            {!newPage && pageCode == 'botComponents' ? <BotComponents commondShow={commondShow} reset={reset} treeContext={treeContext} bridgeData={extra} project={project} modalContext={modalContext} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} className={`${newPage && pageCode == 'botComponents' ? '' : 'none'}`}></BotComponents> : null}
                            {!newPage && pageCode == 'attachComponents' ? <AttachComponents modalContext={modalContext} project={project} onLoaded={(context) => {
                                this.setState({
                                    formContext: context
                                })
                            }} className={`AttachCompon${newPage && pageCode == 'results' ? '' : 'none'}`}></AttachComponents> : null}
                            {!newPage && pageCode == 'results' ? <SubmitResults goInnerPage={this.goInnerPage} pre={extra && extra.pre ? extra.pre : null} preText={extra && extra.preText ? extra.preText : null} continueEdit={this.continueEdit} backHome={this.backHome}></SubmitResults> : null
                            }
                            {!newPage && pageCode == 'ElevationCal' ? <ElevationCal goInnerPage={this.goInnerPage} ></ElevationCal> : null
                            }
                            {!newPage && pageCode == 'PositionCal' ? <PositionCal modalContext={modalContext} goInnerPage={this.goInnerPage}></PositionCal> : null
                            }
                            {!newPage && pageCode == 'BeamLenCal' ? <BeamLenCal modalContext={modalContext} goInnerPage={this.goInnerPage}></BeamLenCal> : null
                            }
                            
                            {!newPage && pageCode == 'PinnerCal' ? <PinnerCal modalContext={modalContext} goInnerPage={this.goInnerPage}></PinnerCal> : null
                            }
                            {!newPage && pageCode == 'adminicula' ? <Adminicula modalContext={modalContext} goInnerPage={this.goInnerPage}></Adminicula> : null
                            }
                            {!newPage && pageCode == 'adminiculaDetail' ? <AdminiculaDetail modalContext={modalContext} goInnerPage={this.goInnerPage}></AdminiculaDetail> : null
                            }
                            {!newPage && pageCode == 'crossSectionList' ? <CrossSectionList modalContext={modalContext} goInnerPage={this.goInnerPage}></CrossSectionList> : null
                            }

                            <div className={`absMiddle bottom ${(!newPage) && pageCode && (["RoadPoints", "topStructure", "botStructure", "sectionComponents", "pierComponents", "OtherLines", "topComponents", "botComponents", "results", "roadDesign", "bridgeMainList", "bridgeChildList", "ElevationCal", "PositionCal", "BeamLenCal", "PinnerCal", "adminiculaDetail", "crossSectionList","adminicula"].includes(pageCode)) ? 'none' : ''}`}>
                                <Button loading={loading} disabled={loading} onClick={this.submit}>提交</Button><Button onClick={this.reset}>重置</Button>
                            </div>
                        </div>
                        <div className={`commondLine absMiddle ${commondShow ? '' : 'commondHide'}`}>
                            <CommondLine clearLogs={this.clearLogs} execlogs={execlogs} scrollLatest={this.scrollLatest} logs={logList}></CommondLine>
                        </div>
                    </div>
                    <div className={`newPage content absMiddle ${newPage ? '' : 'none'}`}>
                        <div className="title absMiddle"><div></div>{newPageTitle}</div>
                        <div className={`absMiddle bottom ${pageCode == 'results' ? 'none' : ''}`}>
                            <Button loading={loading} disabled={loading} onClick={this.submit}>提交</Button><Button onClick={this.reset}>重置</Button><Button onClick={this.continueEdit}>返回</Button>
                        </div>
                    </div>
                </div>
                <ToolConfigModals
                    formContext={formContext}
                    treeContext={treeContext}
                    project={project}
                    dictlist={dictlist}
                    goNewPage={this.goNewPage}
                    goInnerPage={this.goInnerPage}
                    showCommond={this.showCommond}
                    getSocketNews={this.getSocketNews}
                    setFormular={this.setFormular}
                    closeBg={this.closeBg}
                    showBg={this.showBg}
                    extra={extra}
                    parent={this}
                    onLoaded={context => {
                        this.setState({ modalContext: context })
                    }}
                />
                <div className={showBg ? 'bgTrans' : 'none'}></div>
                {
                    showBg ? <div class="spinner"><Icon type="loading" /></div> : undefined
                }
            </div>
        )
    }
}
export default connect(
    ({
        dict: { dictlist },
        project: { current },
    }) => ({
        dictlist,
        project: current,
    })
    , dispatch => ({
        getProjects: (values, onSuccess, onError) => dispatch({
            type: 'project/getProjects',
            payload: {
                onSuccess,
                onError,
                values
            }
        })
    }))(Design);